package com.answerz.module_reportissues.fragment

import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.answerz.module_reportissues.BR
import com.answerz.module_reportissues.R
import com.answerz.module_reportissues.databinding.FragmentComplaintRecordBinding
import com.answerz.module_reportissues.databinding.FragmentRepairReportBinding
import com.answerz.module_reportissues.viewmodel.ComplaintRecordViewModel
import com.answerz.module_reportissues.viewmodel.RepairReportViewModel
import com.czl.base.adapter.ViewPagerFmAdapter
import com.czl.base.base.BaseFragment
import com.czl.base.config.AppConstants
import com.czl.base.route.RouteCenter
import me.yokeyword.fragmentation.SupportFragment

@Route(path = AppConstants.Router.Complaint.F_COMPLAINT_RECORD)
class ComplaintRecordFragment: BaseFragment<FragmentComplaintRecordBinding, ComplaintRecordViewModel>() {
    override fun initContentView(): Int {
        return R.layout.fragment_complaint_record
    }

    override fun initVariableId(): Int {
        return BR.viewModel
    }

    override fun initData() {
        viewModel.tvTitle.set("投诉记录")
        hiddenBottomShadow()

        var noCompleteFragment =
            RouteCenter.navigate(AppConstants.Router.Complaint.F_COMPLAINT_LIST, Bundle().apply {
                putString(AppConstants.BundleKey.OWNER_STATE, "0")
            }) as SupportFragment
        var completeFragment =
            RouteCenter.navigate(AppConstants.Router.Complaint.F_COMPLAINT_LIST, Bundle().apply {
                putString(AppConstants.BundleKey.OWNER_STATE, "1")
            }) as SupportFragment
        var fragments = arrayListOf(noCompleteFragment, completeFragment)
        binding.viewPager.apply {
            adapter = ViewPagerFmAdapter(childFragmentManager, lifecycle, fragments)
        }
    }

    override fun initViewObservable() {
        viewModel.uc.tabChangeLiveEvent.observe(this, {
            binding.viewPager.setCurrentItem(it, false)
        })
        viewModel.uc.pageChangeLiveEvent.observe(this, {
            binding.tabLayout.currentTab = it
        })
    }
}